package com.example.esp32;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.esp32.R;

import java.util.ArrayList;
import java.util.List;

public class GAdapter extends BaseAdapter {
    private Context mContext;
    private List<getValue> mList = new ArrayList<getValue>();

    class ViewHolder {
        TextView kj,dyzt,ip,cid,id;
        ImageView tupian;
    }
    public GAdapter(Context context, List<getValue> list) {
        mContext = context;
        mList = list;
    }
    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        GAdapter.ViewHolder viewHolder = null;
        //初始化卡片样式
        if (view == null) {
            viewHolder = new GAdapter.ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.activity_additme_adapter, null);
            viewHolder.id = view.findViewById(R.id.id);
            viewHolder.dyzt = view.findViewById(R.id.viewid);
//            viewHolder.cid = view.findViewById(R.id.khd);
            viewHolder.kj = view.findViewById(R.id.xhqd);



            view.setTag(viewHolder);
        } else {
            viewHolder = (GAdapter.ViewHolder) view.getTag();
        }

        viewHolder.id.setText(mList.get(i).getas());
        viewHolder.dyzt.setText(mList.get(i).getdyzt());

        viewHolder.kj.setText(mList.get(i).getsbmc());

//        viewHolder.bianji.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mOnItemUpdateListener.onUpdateClick(i);
//            }
//        });

        return view;
    }
}

